#ifndef _UBT_STATE_TASK_CHARGE_EX_H_
#define _UBT_STATE_TASK_CHARGE_EX_H_
#include "ubt_state_types.h"
#include "ubt_state_task_adjust.h"
#include "ubt_state_task_charge.h"
#include "ubt_state_task_nav2.h"

namespace ubt_state
{

class CTaskChargeEx: public ITask, ITaskCb
{
  public:
    static int ClassInit();
    static ITask *CreateTask(ITaskCb *pTaskCb, FixePathTaskInfo *pTaskInfo, int index, int reportIndex, int chargeTime = -1, std::string chargeType = "uslam");
    ~CTaskChargeEx();

    bool Init(ITaskCb *pTaskCb, FixePathTaskInfo *pTaskInfo, int index, int reportIndex,int chargeTime, std::string chargeType = "uslam");

    virtual StateStatus *GetStateStatus();
    virtual void  NotifyTaskEvent(std::string taskEvent);
    virtual void NotifyTaskStateAndStage(int state, int stage, int stateReason, std::string stateReasonDesc);

    virtual bool Start();
    virtual void Pause();
    virtual void Continue();
    virtual void Stop(int reason);
    virtual void OnTimer();
    virtual void OnMsg(int msgType, void *pvMsg);

    virtual ubt_task_type GetType();
    virtual ubt_task_state GetState();
    virtual ubt_task_stage GetStage();
    virtual std::string GetActionType();
    virtual void GetIndex(int& index, int& reportIndex);
    virtual void GetStopInfo(int& stopReason, std::string& stopReasonDesc);
    virtual void GetLogs(std::vector<TaskLogItem>& logs);

  private:
    bool _StartNextLoop();
    void _CleanCurLoop();
    void _StartNextTask();
    std::vector<ubt_state::Line> _CalculateLastChargeLine(FixePathTaskInfo taskInfo);

    std::string _agvType;

    ITaskCb *_pTaskCb;
    FixePathTaskInfo *_pTaskInfo;
    int _index;
    int _reportIndex;
    ubt_task_state _state;
    int _curLoop;//当前次数,0起
    int _maxLoop;
    bool isCharging;

    std::vector<ITask *> _pTaskArr;
    ITask *_curTask;
    int _curTaskIndex;
    bool _isChargePileFail;//是否上桩失败
    int _chargeTime;
    std::string _chargeType;
    std::vector<ubt_state::Line> _lastChargeLines;
};



}

#endif

